package cn.imnu.legalaid.mapper;

import cn.imnu.legalaid.dto.Consultation.MessageDTO;
import cn.imnu.legalaid.entity.ConsultationsMessages;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
* @author 18498
* @description 针对表【consultations_messages(咨询消息表)】的数据库操作Mapper
* @createDate 2025-09-19 17:49:09
* @Entity cn.imnu.legalaid.entity.ConsultationsMessages
*/
public interface ConsultationsMessagesMapper extends BaseMapper<ConsultationsMessages> {

    /**
     * 根据咨询ID查询消息列表（移除@Select注解，使用XML配置）
     */
    List<MessageDTO> selectMessagesByConsultationId(@Param("consultationId") Integer consultationId);

    /**
     * 批量标记消息为已读
     */
    @Update("UPDATE consultations_messages SET Is_read = 1 WHERE consultation_id = #{consultationId} AND id IN " +
            "<foreach collection='messageIds' item='id' open='(' separator=',' close=')'>#{id}</foreach>")
    void markMessagesAsRead(@Param("consultationId") Integer consultationId, @Param("messageIds") List<Integer> messageIds);
}




